<?php

function do_change_password($error) {


	include ('fen_fns.php');
	
?>
	
	<script type="text/javascript" src="scripts/sha512.js"></script>
	<script type="text/javascript" src="scripts/forms.js"></script>
	<script type="text/javascript">

	var oTable;

	$(document).ready(function()
		{
		$(".faculty_id").change(function()
		{
		var id=$(this).val();
		var dataString = 'id='+ id;
		
		$.ajax
			({
			type: "POST",
			url: "reports/ajaxdepartments.php",
			data: dataString,
			cache: false,
			success: function(html)
			{
			$(".department_id").html(html);
			} 
			});
		});
	});

	$(document).ready(function() {

			

		$.ajaxSetup({
	        beforeSend: function(xhr, status) {
	            // TODO: show spinner
	            $('.spinner').show();
	        },
	        complete: function() {
	            // TODO: hide spinner
	            $('.spinner').hide();
	        }
	    });

	    $('#form2 form').submit(function(){
		        $('#reportResult').load('users/dochangepassword.php', {
			        'oldpassword': $('input[name="oldpassword"]').val(),
			        'newpassword': $('input[name="newpassword"]').val(),
			        'newpassword2': $('input[name="newpassword2"]').val()
			    });  
			          
		        $(".contentTopArea").hide();             
		        return false;
		});
    
	});


	function setForm(obj) {  
		//var oldpassword = new LiveValidation(this.form.oldpassword);
		var newpassword = new LiveValidation(this.form.newpassword);
		newpassword.add( Validate.Presence ); newpassword.add( Validate.Length, { minimum: 4, maximum: 20 } );
		alert("k");
	}
	
	</script>
	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv">
				
				<p class="contentMainP">Şifre Bilgileri</p>
				<hr noshade>
				
				<div id="form">
				
				<ul id="ulchangepassword">
				<li>Yeni şifreniz en az 6 karakter uzunluğunda olmalıdır.</li>
				<li>Şifre kontrolü büyük-küçük harfe duyarlıdır.</li>
				</ul>
				<br>

				<form action="users/dochangepassword.php" method="post" name="login_form">

				
				<label for="form1">Eski Şifre:</label> <input type="password" id="oldpassword" name="oldpassword">
				<script type="text/javascript">	var oldpassword = new LiveValidation('oldpassword'); oldpassword.add( Validate.Presence ); oldpassword.add( Validate.Length, { minimum: 4, maximum: 20 } );</script><br>
				
				<label for="form1">Yeni Şifre:</label> <input type="password" id="newpassword" name="newpassword">
				<script type="text/javascript">	var newpassword = new LiveValidation('newpassword'); newpassword.add( Validate.Presence ); newpassword.add( Validate.Length, { minimum: 6, maximum: 20 } );</script><br>
				
				<label for="form1">Yeni Şifre (Tekrar):</label> <input type="password" id="newpassword2" name="newpassword2">
				<script type="text/javascript">	var newpassword2 = new LiveValidation('newpassword2'); newpassword2.add( Validate.Presence ); newpassword2.add( Validate.Length, { minimum: 6, maximum: 20 } ); newpassword2.add( Validate.Confirmation, { match: 'newpassword' } );</script><br>
				
				<br><br>
				<input id="buttonSaveNew" type="submit" value="Değiştir">
		
				
				</form>
				</div>
				<br><br>
			
			</div>
		</div>
	</div>
	<div class="contentMain">

		<div id="reportResult"><img src="images/spinner.gif" class="spinner" alt="loading..." style="display: none;"></div>
		<br><p id="pchangepassworderror"><?php if ($error == '1') { echo "<img src=\"images/erroricon.gif\"></img> &nbsp;Şifreniz değiştirilemedi. Lütfen bilgilerinizi kontrol ederek tekrar deneyiniz!"; } ?></p><br><br><br><br></div>
		
		
	</div>

<?php
}

function do_update_account_info($ok) {


	include ('fen_fns.php');
	
	$query = $_DB->Query("SELECT
			fen_members.email 
			FROM fen_members
			WHERE
			fen_members.username = '".$_SESSION['username']."'");

	$email = $_DB->GetResultValue($query, "0", "email");

	?>
	
	<script type="text/javascript" src="scripts/sha512.js"></script>
	<script type="text/javascript" src="scripts/forms.js"></script>
	<script type="text/javascript">

	var oTable;

	$(document).ready(function()
		{
		$(".faculty_id").change(function()
		{
		var id=$(this).val();
		var dataString = 'id='+ id;
		
		$.ajax
			({
			type: "POST",
			url: "reports/ajaxdepartments.php",
			data: dataString,
			cache: false,
			success: function(html)
			{
			$(".department_id").html(html);
			} 
			});
		});
	});

	$(document).ready(function() {

			

		$.ajaxSetup({
	        beforeSend: function(xhr, status) {
	            // TODO: show spinner
	            $('.spinner').show();
	        },
	        complete: function() {
	            // TODO: hide spinner
	            $('.spinner').hide();
	        }
	    });

	    $('#form2 form').submit(function(){
		        $('#reportResult').load('users/dochangepassword.php', {
			        'oldpassword': $('input[name="oldpassword"]').val(),
			        'newpassword': $('input[name="newpassword"]').val(),
			        'newpassword2': $('input[name="newpassword2"]').val()
			    });  
			          
		        $(".contentTopArea").hide();             
		        return false;
		});
    
	});



	
	</script>
	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv">
				
				<p class="contentMainP">Hesap Bilgileriniz</p>
				<hr noshade>
				
				<div id="form">
				
				
				<br>

				<form action="users/doupdateaccinfo.php" method="post" name="login_form">

				
				<label for="form1">E-posta Adresi:</label> <input type="text" id="email" name="email" value="<?php echo $email; ?>">
				<script type="text/javascript">	var $email = new LiveValidation('email'); $email.add( Validate.Presence ); $email.add( Validate.Email );</script><br>
				<?php if ($ok == '1') { echo "<p id=\"paccinfoupdate\">E-posta adresiniz başarıyla güncellenmiştir.</p>"; } ?>

				<br><br>
				<input id="buttonSaveNew" type="submit" value="Güncelle">
		
				
				</form>
				</div>
				<br><br>
			
			</div>
		</div>
	</div>
	<div class="contentMain">

		<div id="reportResult"><img src="images/spinner.gif" class="spinner" alt="loading..." style="display: none;"></div>
		<br><p id="pchangepassworderror"><?php if ($error == '1') { echo "<img src=\"images/erroricon.gif\"></img> &nbsp;Şifreniz değiştirilemedi. Lütfen bilgilerinizi kontrol ederek tekrar deneyiniz!"; } ?></p><br><br><br><br></div>
		
		
	</div>

<?php
}
